import { FC, CSSProperties, memo } from 'react';
import { Form, Input, Button } from 'antd';

const formItemStyle: CSSProperties = {
  marginBottom: 15,
};

interface Props {
  formSearch(vals: any): void;
}

const Sform: FC<Props> = (props) => {
  const { formSearch } = props;
  const [form] = Form.useForm();

  const onFinish = (vals: any) => {
    formSearch({
      ...vals,
    });
  };

  return (
    <Form form={form} layout="inline" onFinish={onFinish}>
      <Form.Item
        name="project_name__like"
        label="项目名称"
        style={{ ...formItemStyle }}
      >
        <Input allowClear></Input>
      </Form.Item>
      <Form.Item
        name="algorithm_name__like"
        label="模型标识名称"
        style={{ ...formItemStyle }}
      >
        <Input allowClear></Input>
      </Form.Item>

      <Form.Item style={{ ...formItemStyle }}>
        <Button type="primary" htmlType="submit">
          查询
        </Button>
        <Button
          onClick={() => {
            form.resetFields();
            onFinish({});
          }}
          style={{ marginLeft: 15 }}
        >
          重置
        </Button>
      </Form.Item>
    </Form>
  );
};

export default memo(Sform);
